package com.interactiveyang.meet;

import java.util.ArrayList;
import java.util.Collections;

import com.google.gson.Gson;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;

public class OtherShoutPage  extends Activity implements OnClickListener{
	
//	String shoutHistoryFromSQL[];
	ArrayList<String> shoutHistoryFromSQL = new ArrayList<String>();
	Bundle extras;
	
	ListView otherShoutHistory;
	
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		C.setFullScreen(this);
        setContentView(R.layout.othershoutpage);
        
        extras = getIntent().getExtras();
        
        if(extras.containsKey("username")){
        	C.alert(this, extras.getString("username"));
        	
        	String userShout = C.MeetBack.backendRequest.getUserShout(extras.getString("username"));
        	Gson gson = new Gson();
        	
//        	C.alert(this, userShout);
        	
        	UserShout shoutContent = gson.fromJson("{'userShout': " + userShout + "}", UserShout.class);
        	
        	if(userShout != null){
        		for(int i=0; i< shoutContent.userShout.length; i++){
            		shoutHistoryFromSQL.add(shoutContent.userShout[i].shoutcontent);
            	}
        		Collections.reverse(shoutHistoryFromSQL);
        	}
        	
        	
//        	C.alert(this, shoutHistoryFromSQL.get(0));
        }

        otherShoutHistory = (ListView) findViewById(R.id.OtherShoutHistory);
        otherShoutHistory.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, shoutHistoryFromSQL));

	
	}
	
	@Override
	public void onClick(View arg0) {
		// TODO Auto-generated method stub
		
	}

}
